package com.xt.tea.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xt.tea.constant.ApiConstant;
import com.xt.tea.entity.bo.OrderBo;
import com.xt.tea.entity.bo.RequestResult;
import com.xt.tea.entity.domain.Order;
import com.xt.tea.entity.vo.Condition;
import com.xt.tea.entity.vo.OrderVo;
import com.xt.tea.service.OrderService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("订单相关")
@RestController
@RequestMapping(ApiConstant.API_V1+"order")
@AllArgsConstructor
public class OrderController {

    private final OrderService orderService;

    @PostMapping("/getOrder")
    public RequestResult<IPage<OrderBo>> getOrderByCondition(@RequestBody Condition<Order> condition){
       return  RequestResult.success(orderService.getOrderByCondition(condition));
    }

    @PostMapping("/addOrder")
    public RequestResult<OrderVo> addOrder(@RequestBody OrderVo orderVo){
        return RequestResult.success(orderService.addOrder(orderVo));
    }
}
